Product Code Database
Example Keywords: glove -pokimon $4-138
barcode-scavenger
   » » Wiki: Binary Logarithm
Tag Wiki 'Binary Logarithm'.
Tag

In , the binary logarithm () is the to which the number must be to obtain the value . That is, for any real number , x=\log_2 n \quad\Longleftrightarrow\quad 2^x=n. For example, the binary logarithm of is , the binary logarithm of is , the binary logarithm of is , and the binary logarithm of is .

The binary logarithm is the to the base and is the of the power of two function. There are several alternatives to the notation for the binary logarithm; see the Notation section below.

Historically, the first application of binary logarithms was in , by : the binary logarithm of a frequency ratio of two musical tones gives the number of by which the tones differ. Binary logarithms can be used to calculate the length of the representation of a number in the binary numeral system, or the number of needed to encode a message in information theory. In , they count the number of steps needed for and related algorithms. Other areas in which the binary logarithm is frequently used include , , the design of sports , and .

Binary logarithms are included in the standard C mathematical functions and other mathematical software packages.


History
The binary logarithm of a power of two is its position in the ordered sequence of powers of two, and the powers of two have been known since antiquity. They appear in Euclid's Elements, Props. IX.32 (on the of powers of two) and IX.36 (half of the Euclid–Euler theorem, on the structure of even ). The 8th century mathematician defined the concept of ardhacheda to be the number of times a given number can be divided evenly by two. This coincides with the binary logarithm on the powers of two,. but it is different for other integers, giving the rather than the logarithm.See, e.g., . 's 1544 book Arithmetica Integra contains several tables that show the with their corresponding powers of two. Reversing the rows of these tables allow them to be interpreted as tables of binary logarithms, in the same sense that Virasena's ardhacheda, applied to a power of two, can be interpreted as a binary logarithm. .. A copy of the same table with two more entries appears on p. 237, and another copy extended to negative powers appears on p. 249b.

The modern form of a binary logarithm, applying to any number (not just powers of two) was considered explicitly by in 1739. Euler established the application of binary logarithms to music theory, long before their applications in information theory and computer science became known. As part of his work in this area, Euler published a table of binary logarithms of the integers from 1 to 8, to seven decimal digits of accuracy...


Definition and properties
The binary logarithm function may be defined as the to the power of two function, which is a strictly increasing function over the positive and therefore has a unique inverse.. Alternatively, it may be defined as , where is the natural logarithm, defined in any of its standard ways. Using the complex logarithm in this definition allows the binary logarithm to be extended to the .For instance, provides the IMLOG2 function for complex binary logarithms: see .

As with other logarithms, the binary logarithm obeys the following equations, which can be used to simplify formulas that combine binary logarithms with multiplication or exponentiation:. \log_2 xy=\log_2 x + \log_2 y \log_2\frac{x}{y}=\log_2 x - \log_2 y \log_2 x^y = y\log_2 x. For more, see list of logarithmic identities.


Notation
In mathematics, the binary logarithm of a number is often written as .For instance, this is the notation used in the Encyclopedia of Mathematics and The Princeton Companion to Mathematics. However, several other notations for this function have been used or proposed, especially in application areas.

Some authors write the binary logarithm as ,. the notation listed in The Chicago Manual of Style.. credits this notation to a suggestion of ,, p. 11. The same notation was in the 1973 2nd edition of the same book (p. 23) but without the credit to Reingold. but its use in both information theory and computer science dates to before Reingold was active... The binary logarithm has also been written as with a prior statement that the default base for the logarithm is .... from dualis]] or logarithmus dyadis. The , ISO 31-11 and ISO 80000-2 standards recommend yet another notation, . According to these standards, should not be used for the binary logarithm, as it is instead reserved for the .For DIN 1302 see .For ISO 31-11 see .For ISO 80000-2 see .


Applications

Information theory
The number of digits () in the binary representation of a positive integer is the integral part of , i.e. \lfloor \log_2 n\rfloor + 1.

In information theory, the definition of the amount of and information entropy is often expressed with the binary logarithm, corresponding to making the bit the fundamental unit of information. With these units, the Shannon–Hartley theorem expresses the information capacity of a channel as the binary logarithm of its signal-to-noise ratio, plus one. However, the natural logarithm and the nat are also used in alternative notations for these definitions..


Combinatorics
Although the natural logarithm is more important than the binary logarithm in many areas of pure mathematics such as and mathematical analysis,. the binary logarithm has several applications in :
  • Every with leaves has height at least , with equality when is a power of two and the tree is a complete binary tree.. Relatedly, the of a river system with tributary streams is at most ..
  • Every family of sets with different sets has at least elements in its union, with equality when the family is a .Equivalently, a family with distinct elements has at most distinct sets, with equality when it is a power set.
  • Every with vertices has isometric dimension at least , and has at most edges, with equality when the partial cube is a ..
  • According to Ramsey's theorem, every -vertex has either a clique or an independent set of size logarithmic in . The precise size that can be guaranteed is not known, but the best bounds known on its size involve binary logarithms. In particular, all graphs have a clique or independent set of size at least and almost all graphs do not have a clique or independent set of size larger than ..
  • From a mathematical analysis of the Gilbert–Shannon–Reeds model of random shuffles, one can show that the number of times one needs to shuffle an -card deck of cards, using , to get a distribution on permutations that is close to uniformly random, is approximately . This calculation forms the basis for a recommendation that 52-card decks should be shuffled seven times..


Computational complexity
The binary logarithm also frequently appears in the analysis of algorithms, If a problem initially has choices for its solution, and each iteration of the algorithm reduces the number of choices by a factor of two, then the number of iterations needed to select a single choice is again the integral part of . This idea is used in the analysis of several and . For example, in , the size of the problem to be solved is halved with each iteration, and therefore roughly iterations are needed to obtain a solution for a problem of size .. Similarly, a perfectly balanced binary search tree containing elements has height ..

The running time of an algorithm is usually expressed in big O notation, which is used to simplify expressions by omitting their constant factors and lower-order terms. Because logarithms in different bases differ from each other only by a constant factor, algorithms that run in time can also be said to run in, say, time. The base of the logarithm in expressions such as or is therefore not important and can be omitted.. However, for logarithms that appear in the exponent of a time bound, the base of the logarithm cannot be omitted. For example, is not the same as because the former is equal to and the latter to .

Algorithms with running time are sometimes called ., p. 186. Some examples of algorithms with running time or are:

details="Page 238"/>
  • Searching in balanced binary search trees
details="Page 159"/>
  • Exponentiation by squaring
details="Page 464"/>
  • Longest increasing subsequence.
Binary logarithms also occur in the exponents of the time bounds for some divide and conquer algorithms, such as the Karatsuba algorithm for multiplying -bit numbers in time , and the Strassen algorithm for multiplying matrices in time . The occurrence of binary logarithms in these running times can be explained by reference to the master theorem for divide-and-conquer recurrences.


Bioinformatics
In , are used to measure how strongly different genes are expressed in a sample of biological material. Different rates of expression of a gene are often compared by using the binary logarithm of the ratio of expression rates: the log ratio of two expression rates is defined as the binary logarithm of the ratio of the two rates. Binary logarithms allow for a convenient comparison of expression rates: a doubled expression rate can be described by a log ratio of , a halved expression rate can be described by a log ratio of , and an unchanged expression rate can be described by a log ratio of zero, for instance..

Data points obtained in this way are often visualized as a in which one or both of the coordinate axes are binary logarithms of intensity ratios, or in visualizations such as the and that rotate and scale these log ratio scatterplots..


Music theory
In , the interval or perceptual difference between two tones is determined by the ratio of their frequencies. Intervals coming from ratios with small numerators and denominators are perceived as particularly euphonious. The simplest and most important of these intervals is the , a frequency ratio of . The number of octaves by which two tones differ is the binary logarithm of their frequency ratio..

To study and other aspects of music theory that require finer distinctions between tones, it is helpful to have a measure of the size of an interval that is finer than an octave and is additive (as logarithms are) rather than multiplicative (as frequency ratios are). That is, if tones , , and form a rising sequence of tones, then the measure of the interval from to plus the measure of the interval from to should equal the measure of the interval from to . Such a measure is given by the cent, which divides the octave into equal intervals ( of cents each). Mathematically, given tones with frequencies and , the number of cents in the interval from to is \left|1200\log_2\frac{f_1}{f_2}\right|. The is defined in the same way, but with a multiplier of instead of ..


Sports scheduling
In competitive games and sports involving two players or teams in each game or match, the binary logarithm indicates the number of rounds necessary in a single-elimination tournament required to determine a winner. For example, a tournament of players requires rounds to determine the winner, a tournament of teams requires rounds, etc. In this case, for players/teams where is not a power of 2, is rounded up since it is necessary to have at least one round in which not all remaining competitors play. For example, is approximately , which rounds up to , indicating that a tournament of teams requires rounds (either two teams sit out the first round, or one team sits out the second round). The same number of rounds is also necessary to determine a clear winner in a Swiss-system tournament..


Photography
In , are measured in terms of the binary logarithm of the amount of light reaching the film or sensor, in accordance with the Weber–Fechner law describing a logarithmic response of the human visual system to light. A single stop of exposure is one unit on a base- logarithmic scale. page 228"/>. More precisely, the exposure value of a photograph is defined as \log_2 \frac{N^2}{t} where is the measuring the of the lens during the exposure, and is the number of seconds of exposure. page 235"/>

Binary logarithms (expressed as stops) are also used in , to express the of light-sensitive materials or digital sensors..


Calculation

Conversion from other bases
An easy way to calculate on that do not have a function is to use the natural logarithm () or the ( or ) functions, which are found on most scientific calculators. To change the logarithm base to 2 from , , or any other base , one can use the :. \log_2 n = \frac{\ln n}{\ln 2} = \frac{\log_{10} n}{\log_{10} 2} = \frac{\log_{b} n}{\log_{b} 2}\,. Approximately, \log_2 n \approx 1.442695\ln n \approx 3.321928\log_{10} n\,.


Integer rounding
The binary logarithm can be made into a function from integers and to integers by it up or down. These two forms of integer binary logarithm are related by this formula: \lfloor \log_2(n) \rfloor = \lceil \log_2(n + 1) \rceil - 1, \text{ if }n \ge 1. The definition can be extended by defining \lfloor \log_2(0) \rfloor = -1. Extended in this way, this function is related to the number of leading zeros of the 32-bit unsigned binary representation of , . \lfloor \log_2(n) \rfloor = 31 - \operatorname{nlz}(n).

The integer binary logarithm can be interpreted as the zero-based index of the most significant bit in the input. In this sense it is the complement of the find first set operation, which finds the index of the least significant bit. Many hardware platforms include support for finding the number of leading zeros, or equivalent operations, which can be used to quickly find the binary logarithm. The fls and flsl functions in the fls, Linux kernel API, kernel.org, retrieved 2010-10-17. and in some versions of the software library also compute the binary logarithm (rounded up to an integer, plus one).


Piecewise-linear approximation
For a number x represented in as x=2^E(1+m), with integer exponent E and m in the range 0\le m<1, the binary logarithm can be roughly approximated as \log_2 x\approx E+m. This approximation is exact at both ends of the range of mantissas but underestimates the logarithm in the middle of the range, reaching a maximum error of approximately 0.086 at a mantissa of approximately 0.44. It can be made more accurate by using a piecewise linear function of m, or more crudely by adding a constant correction term \log_2 x\approx E+m+\sigma. For instance choosing \sigma\approx 0.043 would halve the maximum error. The fast inverse square root algorithm uses this idea, with a different correction term that can be inferred to be \sigma\approx 0.0450466, by directly manipulating the binary representation of x to multiply this approximate logarithm by -\tfrac12, obtaining a floating point value that approximates 1/\sqrt x.


Iterative approximation
For a general , the binary logarithm may be computed in two parts.. First, one computes the integer part, \lfloor\log_2 x\rfloor (called the characteristic of the logarithm). This reduces the problem to one where the argument of the logarithm is in a restricted range, the interval , simplifying the second step of computing the fractional part (the mantissa of the logarithm). For any , there exists a unique integer such that , or equivalently . Now the integer part of the logarithm is simply , and the fractional part is . In other words: \log_2 x = n + \log_2 y \quad\text{where } y = 2^{-n}x \text{ and } y \in [1,2) For normalized numbers, the integer part is given by the floating-point exponent,. and for integers it can be determined by performing a count leading zeros operation..

The fractional part of the result is and can be computed iteratively, using only elementary multiplication and division. The algorithm for computing the fractional part can be described in as follows:

  1. Start with a real number in the half-open interval . If , then the algorithm is done, and the fractional part is zero.
  2. Otherwise, square repeatedly until the result lies in the interval . Let be the number of squarings needed. That is, with chosen such that is in .
  3. Taking the logarithm of both sides and doing some algebra: \begin{align}
\log_2 z &= 2^m \log_2 y \\
\log_2 y &= \frac{ \log_2 z }{ 2^m } \\
         &= \frac{ 1 + \log_2(z/2) }{ 2^m } \\
         &= 2^{-m} + 2^{-m}\log_2(z/2).
     
\end{align}
  1. Once again is a real number in the interval . Return to step 1 and compute the binary logarithm of using the same method.

The result of this is expressed by the following recursive formulas, in which m_i is the number of squarings required in the -th iteration of the algorithm: \begin{align}

\log_2 x &= n + 2^{-m_1} \left( 1 + 2^{-m_2} \left( 1 + 2^{-m_3} \left( 1 + \cdots \right)\right)\right) \\
         &= n + 2^{-m_1} + 2^{-m_1-m_2} + 2^{-m_1-m_2-m_3} + \cdots
     
\end{align}

In the special case where the fractional part in step 1 is found to be zero, this is a finite sequence terminating at some point. Otherwise, it is an that converges according to the , since each term is strictly less than the previous one (since every ). See Horner's method. For practical use, this infinite series must be truncated to reach an approximate result. If the series is truncated after the -th term, then the error in the result is less than .


Software library support
The log2 function is included in the standard C mathematical functions. The default version of this function takes arguments but variants of it allow the argument to be single-precision or to be a .. In computing environments supporting and implicit type conversion such as the argument to the log2 function is allowed to be a , returning a complex one..


External links

Page 1 of 1
1
Page 1 of 1
1

Account

Social:
Pages:  ..   .. 
Items:  .. 

Navigation

General: Atom Feed Atom Feed  .. 
Help:  ..   .. 
Category:  ..   .. 
Media:  ..   .. 
Posts:  ..   ..   .. 

Statistics

Page:  .. 
Summary:  .. 
1 Tags
10/10 Page Rank
5 Page Refs